package com.spongebob.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.spongebob.pojo.SessionMessage;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 会话管理 Mapper 接口
 * </p>
 *
 * @author tutu
 * @since 2021-03-16
 */
public interface SessionMessageMapper extends BaseMapper<SessionMessage> {

    @Select("SELECT sessionId FROM `session_message` where customerServiceId=#{customerServiceId} GROUP BY sessionId")
    public List<Integer> selectAllSession(Integer customerServiceId);

    @Select("SELECT * FROM session_message WHERE  sendTime=(SELECT MAX(sendTime) FROM session_message WHERE sessionId=#{sessionid} )")
    public SessionMessage getMessage(Integer sessionid);

}
